home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / mnp_c.zip / SUSPEND.ASM < prev    next >
Assembly Source File  |  1990-05-16  |  2KB  |  72 lines

  1.     TITLE suspend.asm ...suspend (n) 100 msec periods.
  2.     page    60,132
  3. ;==============================================================================
  4. ;
  5. ;               The Microcom MNP Library
  6. ;            (Microsoft C Version)
  7. ;
  8. ;------------------------------------------------------------------------------
  9. ;
  10. ;    suspend - wait n 100 msec periods
  11. ;
  12. ;    synopsis: suspend(n);
  13. ;
  14. ;            int n;        number of periods
  15. ;
  16. ;==============================================================================
  17.  
  18. _data    segment word public 'DATA'
  19. _data    ends
  20. dgroup    group    _data
  21.  
  22. _text    segment byte public 'CODE'
  23.     assume    cs:_text,ds:dgroup
  24.  
  25.     public    _suspend
  26.  
  27. ;PUBLIC****************************************************************
  28. ;
  29. ;    suspend - wait n 100ms periods
  30. ;
  31. ;**********************************************************************
  32.  
  33. _suspend proc near
  34.  
  35.     push    bp
  36.     mov    bp,sp
  37.  
  38.     mov    al, byte ptr[bp+4]    ; get time to suspend
  39. ;
  40. w0:    
  41.     push    ax
  42.     mov    ah,2ch            ;get time of day
  43.     int    21h            ;  from dos
  44.     mov    bl,dl            ;save hundredths value
  45.     pop    ax
  46. ;
  47. ; loop until the time-of-day clock indicates that 10x.01 seconds
  48. ; have gone by.
  49. w1:    
  50.     push    ax            ;save count
  51.     mov    ah,2ch            ;get time again
  52.     int    21h
  53.     cmp    dl,bl            ;wrap?
  54.     jge    w2            ;no-go on
  55.     add    dl,100            ;yes-compensate
  56. w2:    
  57.     sub    dl,bl            ;get difference between then and now
  58.     cmp    dl,10            ;has 100 ms gone by?
  59.     pop    ax
  60.     jl    w1            ;no-go again
  61. ;
  62.     dec    al            ;count down
  63.     jnz    w0            ;loop until done
  64. ;
  65.     pop    bp            ;restore bp
  66.     ret
  67.  
  68. _suspend endp
  69.  
  70. _text    ends
  71.     end
  72.